using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class OrderControl
    {
        #region Local Variable
        private OrderDataAccess _objDAO;
        #endregion Local Variable

        #region Method
        public OrderControl()
        {
            _objDAO = new OrderDataAccess();
        }

        public OrderInfo Get(
        Int32 ID,
        ref string sErr)
        {
            return _objDAO.Get(
            ID,
            ref sErr);
        }

        public DataTable GetAll(
        ref string sErr)
        {
            return _objDAO.GetAll(
            ref sErr);
        }
        public DataTable GetByPos(
        int pos, ref string sErr)
        {
            return _objDAO.GetByPos(
            pos, ref sErr);
        }
        public int GetCountRecord(
        ref string sErr)
        {
            return _objDAO.GetCountRecord(
            ref sErr);
        }

        public Int32 Add(OrderInfo obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }

        public string Update(OrderInfo obj)
        {
            return _objDAO.Update(obj);
        }

        public string Delete(
        Int32 ID
        )
        {
            return _objDAO.Delete(
            ID
            );
        }
        public Boolean IsExist(
        Int32 ID
        )
        {
            return _objDAO.IsExist(
            ID
            );
        }

        public DataTableCollection Get_Page(OrderInfo obj, string orderBy, int pageIndex, int pageSize, ref String sErr)
        {
            return _objDAO.Get_Page(obj, orderBy, pageIndex, pageSize, ref sErr);
        }

        public DataTable Search(String columnName, String columnValue, String condition, String tableName, ref String sErr)
        {
            return _objDAO.Search(columnName, columnValue, condition, tableName, ref  sErr);
        }
        public string InsertUpdate(OrderInfo obj)
        {
            string sErr = "";
            if (IsExist(
            obj.ID
            ))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            return OrderInfo.ToDataTable();
        }

        public string TransferIn(DataRow row)
        {
            OrderInfo inf = new OrderInfo(row);
            return InsertUpdate(inf);
        }
        #endregion Method
        public DataTable GetAll_OrderEx(ref string _sErr)
        {
            return _objDAO.GetAll_OrderEx(ref  _sErr);
        }

        public DataTable Get_ByUserID(
       Int32 ID,
       ref string sErr)
        {
            return _objDAO.Get_ByUserID(ID, ref sErr);
        }

    }
}
